home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / inet / internet-drafts / draft-ietf-avt-video-packet-01.txt < prev    next >
Text File  |  1993-06-07  |  26KB  |  941 lines

  1.  
  2.  
  3.  
  4. Internet Engineering Task Force       Audio-Video Transport WG
  5. INTERNET-DRAFT                          T.Turletti, C. Huitema
  6.                                                          INRIA
  7.                                                         May 93
  8.                                               Expires: Nov. 93
  9.  
  10.                         Packetization
  11.                              of
  12.                      H.261 video streams
  13.  
  14.  
  15.  
  16.                          May 28, 1993
  17.  
  18.              Thierry Turletti, Christian Huitema
  19.                             INRIA
  20.  
  21.               Christian.Huitema@sophia.inria.fr
  22.                Thierry.Turletti@sophia.inria.fr
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29. 1.  Status of this Memo
  30.  
  31. This document is an Internet draft. Internet drafts are
  32. working documents of the Internet Engineering Task Force
  33. (IETF), its Areas, and its Working Groups. Note that other
  34. groups may also distribute working documents as Internet
  35. Drafts).
  36.  
  37. Internet Drafts are draft documents valid for a maximum of six
  38. months. Internet Drafts may be updated, replaced, or obsoleted
  39. by other documents at any time. It is not appropriate to use
  40. Internet Drafts as reference material or to cite them other
  41. than as a "working draft" or "work in progress".
  42.  
  43. Please check the I-D abstract listing contained in each
  44. Internet Draft directory to learn the current status of this
  45. or any other Internet Draft.
  46.  
  47. Distribution of this document is unlimited.
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60. INTERNET-DRAFT                    Packetization of H.261
  61.  
  62.  
  63. 2.  Abstract
  64.  
  65. This draft describes a packetization scheme of H.261 video
  66. stream.  The scheme proposed can be used to transport such a
  67. video flow over the protocols used by RTP.
  68.  
  69. This specification is a product  of the Audio-Video Transport
  70. working  group within the Internet  Engineering Task  Force.
  71. Comments  are solicited  and should be addressed to the
  72. working group's mailing list at  rem-conf@es.net and/or the
  73. authors.
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113. Turletti, Huitema                                     [Page 2]
  114.  
  115.  
  116.  
  117.  
  118.  
  119. INTERNET-DRAFT                    Packetization of H.261
  120.  
  121.  
  122. 3.  Purpose of this document
  123.  
  124. The CCITT recommendation H.261 [1] specifies the encodings
  125. used by CCITT compliant video-conference codecs. Although
  126. these encodings were originally specified for fixed data rate
  127. ISDN circuits, experimentations [2]  have shown that they can
  128. also be used over the internet.
  129.  
  130. The purpose of this memo is to specify how H.261 video streams
  131. can be carried over the protocols used by RTP [3], such as
  132. UDP, ST-II, etc.
  133.  
  134.  
  135. 4.  Structure of the packet stream
  136.  
  137. H.261 codecs produce a bit stream. In fact, H.261 and
  138. companion recommendations specify several levels of encoding:
  139.  
  140. (1)  Images are first separated in blocks of 8x8 pixels.
  141.      Blocks which have moved are encoded by computing the
  142.      discrete cosine transform (DCT) of their coefficients,
  143.      which are then quantized and Huffman encoded.
  144.  
  145. (2)  The bits resulting of the Huffman encoding are then
  146.      arranged in 512 bits frames, containing 2 bits of
  147.      synchronization, 492 bits of data and 18 bits of error
  148.      correcting code.
  149.  
  150. (3)  The 512 bits frames are then interlaced with an audio
  151.      stream and transmitted over px64 kbps circuits according
  152.      to specification H.221.
  153.  
  154. When transmitting over the Internet, we will directly consider
  155. the output of the Huffman encoding. We will not carry the 512
  156. bits frames, as protection against errors can be obtained by
  157. other means. Similarly, we will not attempt to multiplex audio
  158. and video signals in the same packets, as UDP and RTP provide
  159. a much more efficient way to achieve multiplexing.
  160.  
  161. Directly transmitting the result of the Huffman encoding over
  162. an unreliable stream of UDP datagrams would however have very
  163. poor error resistance characteristics. The H.261 coding is in
  164. fact organized as a sequence of images, or frames, which are
  165. themselves organized as a set of Groups of Blocks (GOB). Each
  166. GOB holds a set of 3 lines of 11 macro blocs (MB). Each MB
  167.  
  168.  
  169.  
  170.  
  171.  
  172. Turletti, Huitema                                     [Page 3]
  173.  
  174.  
  175.  
  176.  
  177.  
  178. INTERNET-DRAFT                    Packetization of H.261
  179.  
  180.  
  181. carries information on a group of 16x16 pixels: luminance
  182. information is specified for 4 blocks of 8x8 pixels, while
  183. chrominance information is only given by two color difference
  184. components 8x8 "red" and "blue" blocks. These components and
  185. the codes representing their sampled values are as defined in
  186. the CCIR Recommendation 601.
  187.  
  188. This grouping is used to specify informations at each level of
  189. the hierarchy:
  190.  
  191. -    At the frame level, one specifies informations such as
  192.      the delay from the previous frame, the image format, and
  193.      various indicators.
  194.  
  195. -    At the GOB level, one specifies the GOB number and the
  196.      default quantifier that will be used for the MBs.
  197.  
  198. -    At the MB level, one specifies which blocks are presents
  199.      and which did not change, and optionally a quantifier, as
  200.      well as precisions on the codings such as distance
  201.      vectors.
  202.  
  203. The result of this structure is that one need to receive the
  204. informations present in the frame header to decode the GOBs,
  205. as well as the informations present in the GOB header to
  206. decode the MBs. Without precautions, this would mean that one
  207. has to receive all the packets that carry an image in order to
  208. properly decode its components. In fact, the experience as
  209. shown that:
  210.  
  211. (1)  It would be unrealistic to carry an image on a single
  212.      packet: video images can sometimes be very large.
  213.  
  214. (2)  GOB informations typically fits in a packet. In fact,
  215.      several GOBs can often be grouped in a packet.
  216.  
  217. Once we have take the decision to correlate GOB
  218. synchronization and packetization, a number of decisions
  219. remain to be taken, due to the following conditions:
  220.  
  221. (1)  The algorithm should be easy to implement when
  222.      packetizing the output stream of a hardware codec.
  223.  
  224. (2)  The algorithm should not induce rendition delays -- we
  225.      should not have to wait for a following packet to display
  226.  
  227.  
  228.  
  229.  
  230.  
  231. Turletti, Huitema                                     [Page 4]
  232.  
  233.  
  234.  
  235.  
  236.  
  237. INTERNET-DRAFT                    Packetization of H.261
  238.  
  239.  
  240.      an image.
  241.  
  242. (3)  The algorithm should allow for efficient
  243.      resynchronization in case of packet losses.
  244.  
  245. (4)  It should be easy to depacketize the data stream and
  246.      direct it to an hardware codec's input.
  247.  
  248. (5)  When the hardware decoder operates at a fixed bit rate,
  249.      one should be able to maintain synchronization, e.g. by
  250.      adding padding bits when the packet arrival rate is
  251.      slower than the bit rate.
  252.  
  253. The H.261 Huffmans encoding includes a special "GOB start"
  254. pattern, composed of 15 zeroes followed by a single 1, that
  255. cannot be imitated by any other code words. That patterns mark
  256. the separation between two GOBs, and is in fact used as an
  257. indicator that the current GOB is terminated. The encoding
  258. also include a stuffing pattern, composed of seven zeroes
  259. followed by four ones; that stuffing pattern can only be
  260. entered between the encoding of MBs, or just before the GOB
  261. separator.
  262.  
  263. The first conclusion of the analysis is that the packets
  264. should contain all the GOB data, including the "GOB start"
  265. pattern that separate the current block from its follower.
  266. Actually, as this pattern is well known, we could as well use
  267. a single bit in the data header to indicate that a GOB-start
  268. pattern must be added at the decoder side.
  269.  
  270.  
  271. Not encoding the GOB-start pattern has two advantages:
  272.  
  273. (1)  It reduces the number of bits in the packets, and avoids
  274.      the possibility of splitting packets in the middle of a
  275.      GOB separator.
  276.  
  277. (2)  It authorizes gateways to hardware decoders to insert the
  278.      stuffing pattern in front of the GOB, in order to meet
  279.      the fixed bit rate requirement.
  280.  
  281. Another problem posed by the specificities of the H.261
  282. compression is that the GOB data have no particular reason to
  283. fit in an integer number of octets.  The data header will thus
  284. contain two three bits integers, EBIT and SBIT:
  285.  
  286.  
  287.  
  288.  
  289.  
  290. Turletti, Huitema                                     [Page 5]
  291.  
  292.  
  293.  
  294.  
  295.  
  296. INTERNET-DRAFT                    Packetization of H.261
  297.  
  298.  
  299. SBIT indicates the number of bits that should be ignored in
  300.      the first (start) data octet.
  301.  
  302. EBIT indicates the number of bits that should be ignored in
  303.      the last (end) data octet.
  304.  
  305. Although only the EBIT counter would really be needed for
  306. software coders, the SBIT counter was inserted to ease the
  307. packetization of hardware coders output.  A sample
  308. packetization procedure is found in annex A.
  309.  
  310. At the receiving sites, the GOB synchronization can be used in
  311. conjunction with the synchronization service of the RTP
  312. protocol. In case of losses, the decoders could become
  313. desynchronized. The "S" bit of the H.261 option field will be
  314. set to indicate that the packet includes the beginning of the
  315. encoding of a GOB, i.e. the quantifier common to all macro
  316. blocks. The receiver will detect losses by looking at the RTP
  317. sequence numbers. The receiver may either resequence out of
  318. order packets or merely drop them. In case of losses, it will
  319. ignore all packets whose "S" bit is null. Once an S bit packet
  320. has been received, it will prepend the GOB start code to that
  321. packet, and resume decoding.
  322.  
  323. An example packetization program is given in Appendix A.
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349. Turletti, Huitema                                     [Page 6]
  350.  
  351.  
  352.  
  353.  
  354.  
  355. INTERNET-DRAFT                    Packetization of H.261
  356.  
  357.  
  358. 5.  Usage of RTP
  359.  
  360. The H.261 informations are carried as data within the RTP
  361. protocol, using the following informations:
  362.  
  363.         _____________________________________________
  364.        | Ver       |   Protocol version (1).        |
  365.        |___________|________________________________|
  366.        | Flow      |   Identifies one particular    |
  367.        |           |   video stream.                |
  368.        |___________|________________________________|
  369.        | Content   |   H.261 encoded video (31).    |
  370.        |___________|________________________________|
  371.        | Sequence  |   Identifies the packet within |
  372.        | number    |   a stream                     |
  373.        |___________|________________________________|
  374.        | Sync      |   Set if the packet            |
  375.        |           |   includes the end of an image.|
  376.        |___________|________________________________|
  377.        | Timestamp |   The date at which the        |
  378.        |           |   image was grabbed.           |
  379.        |___________|________________________________|
  380.  
  381.  
  382. The very definition of this settings implies that the
  383. beginning of an image shall always be synchronized with a
  384. packet. The RTP sequence number can be used to detect missing
  385. packets. In this case, one shall ignore all incomings packets
  386. until the next synchronization mark is received. The "Sync"
  387. bit can be used as a flag to trigger display the new image on
  388. the screen.  The H.261 data will follow the RTP options, as
  389. in:
  390.  
  391.   0                   1                   2                   3
  392.   0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  393.  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  394.  .                                                               .
  395.  .              RTP header + RTP options (optional)              .
  396.  .                                                               .
  397.  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  398.  |        H.261  options         |         H.261 stream...       |
  399.  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  400.  
  401. The H.261 options field is defined as following:
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408. Turletti, Huitema                                     [Page 7]
  409.  
  410.  
  411.  
  412.  
  413.  
  414. INTERNET-DRAFT                    Packetization of H.261
  415.  
  416.  
  417.   0                   1
  418.   0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
  419.  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  420.  |S|SBIT |E|EBIT |C|I|V|MBZ| FMT |
  421.  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  422.  
  423.    _______________________________________________________
  424.   | S (1 bit)     |   Start of GOB. Set if               |
  425.   |               |   the packet is a start of GOB.      |
  426.   |_______________|______________________________________|
  427.   | SBIT (3 bits) |   Start bit position                 |
  428.   |               |   number of bits that should         |
  429.   |               |   be ignored in the first            |
  430.   |               |   (start) data octet.                |
  431.   |_______________|______________________________________|
  432.   | E (1 bit)     |   End of GOB. Set if                 |
  433.   |               |   the packet is an end of GOB.       |
  434.   |_______________|______________________________________|
  435.   | EBIT (3 bits) |   End bit position                   |
  436.   |               |   number of bits that should         |
  437.   |               |   be ignored in the last             |
  438.   |               |   (end) data octet.                  |
  439.   |_______________|______________________________________|
  440.   | C (1 bit)     |   Color flag. Set if                 |
  441.   |               |   color is encoded.                  |
  442.   |_______________|______________________________________|
  443.   | I (1 bit)     |   Full Intra Image flag.             |
  444.   |               |   Set if it is the first packet      |
  445.   |               |   of a full intra image.             |
  446.   |_______________|______________________________________|
  447.   | V (1 bit)     |   movement Vector flag.              |
  448.   |               |   Set if movement vectors            |
  449.   |               |   are encoded.                       |
  450.   |_______________|______________________________________|
  451.   | FMT (3 bits)  |   Image format:                      |
  452.   |               |   QCIF, CIF or number of CIF in SCIF.|
  453.   |_______________|______________________________________|
  454.   | MBZ (2 bits)  |   Must be zero.                      |
  455.   |_______________|______________________________________|
  456.  
  457.  
  458. The image format (3 bits) is defined as following:
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467. Turletti, Huitema                                     [Page 8]
  468.  
  469.  
  470.  
  471.  
  472.  
  473. INTERNET-DRAFT                    Packetization of H.261
  474.  
  475.  
  476.                  ____________________________
  477.                 | QCIF               |   000|
  478.                 |____________________|______|
  479.                 | CIF                |   001|
  480.                 |____________________|______|
  481.                 | SCIF 0             |      |
  482.                 | upper left corner  |   100|
  483.                 | CIF in SCIF image  |      |
  484.                 |____________________|______|
  485.                 | SCIF 1             |      |
  486.                 | upper right corner |   101|
  487.                 | CIF in SCIF image  |      |
  488.                 |____________________|______|
  489.                 | SCIF 2             |      |
  490.                 | lower left corner  |   110|
  491.                 | CIF in SCIF image  |      |
  492.                 |____________________|______|
  493.                 | SCIF 3             |      |
  494.                 | lower right corner |   111|
  495.                 | CIF in SCIF image  |      |
  496.                 |____________________|______|
  497.  
  498.  
  499. With:
  500.  
  501. -    CIF: Common interchange format for video images with 352
  502.      x 288 pixels.
  503.  
  504. -    QCIF: Quarter CIF with 176 x 144 pixels.
  505.  
  506. -    SCIF: Super CIF with 704 x 288 pixels.
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526. Turletti, Huitema                                     [Page 9]
  527.  
  528.  
  529.  
  530.  
  531.  
  532. INTERNET-DRAFT                    Packetization of H.261
  533.  
  534.  
  535. 6.  Usage of RTP parameters
  536.  
  537. When sending or receiving H.261 streams through the RTP
  538. protocol, the stations should be ready to:
  539.  
  540. (1)  process or ignore all generic RTP parameters,
  541.  
  542. (2)  send or receive H.261 specific "Reverse Application Data"
  543.      parameters, to request a video resynchronization.
  544.  
  545. This memo describes two "RAD" item types, "Full Intra Request"
  546. and "Negative Acknowledge".
  547.  
  548. 6.1.  Controlling the reverse flow
  549.  
  550. Support of the reverse application data by the H.261 sender is
  551. optional; in particular, early experiments have shown that the
  552. usage of this feature could have very negative effects when
  553. the number of recipients is very large.
  554.  
  555. Recipients learn the return address where RAD informations may
  556. be sent from the Content description (CDESC) item, which may
  557. be included as an RTP option in any of the video packets. The
  558. CDESC item includes a Return port number value. A value of
  559. zero indicates that no reverse control information should be
  560. returned.
  561.  
  562. A recipient shall never send a RAD item if it has not yet
  563. received a CDESC item from the source, or if the port number
  564. received in the last CDESC item was null.
  565.  
  566. Emitters should identify themselves by sending CDESC items at
  567. regular intervals.
  568.  
  569. 6.2.  Full Intra Request
  570.  
  571. The "Full Intra Request" items are identified by the item Type
  572. "FIR" (0).
  573.  
  574.   0                   1                   2                   3
  575.   0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  576.  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  577.  |F|    RAD      |  length = 1   |   Type        | Z |   Flow    |
  578.  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585. Turletti, Huitema                                    [Page 10]
  586.  
  587.  
  588.  
  589.  
  590.  
  591. INTERNET-DRAFT                    Packetization of H.261
  592.  
  593.  
  594. These packets indicate that a recipient has lost all video
  595. synchronization, and request the source to send the next image
  596. in "Intra" coding mode, i.e.  without using differential
  597. coding. The various fields are defined as follow:
  598.  
  599.        ________________________________________________
  600.       | F      |   Last option bit, as defined by RTP.|
  601.       |________|______________________________________|
  602.       | RAD    |   RAD option type (65)               |
  603.       |________|______________________________________|
  604.       | Length |   In 32-bits word.                   |
  605.       |________|______________________________________|
  606.       | Type   |   FIR (0).                           |
  607.       |________|______________________________________|
  608.       |  Z     |   Must be zero                       |
  609.       |________|______________________________________|
  610.       | Flow   |   The flow id of the incoming packets|
  611.       |________|______________________________________|
  612.  
  613.  
  614. 6.3.  Negative Acknowledgements
  615.  
  616. Packet losses are detected using the RTP sequence number.
  617. After a packet loss, the receiver will resynchronize on the
  618. next GOB. However, as H.261 uses differential encoding, parts
  619. of the images may remain blurred for a rather long time.
  620.  
  621. As all GOB belonging to a given video image carry the same
  622. time stamp, the receiver can determine a list of GOBs which
  623. were really received for that time stamp, and thus identify
  624. the "missing blocks". Requesting a specific reinitialization
  625. of these missing blocks is more efficient than requesting a
  626. complete reinitialization of the image through the "Full Intra
  627. Request" item.
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644. Turletti, Huitema                                    [Page 11]
  645.  
  646.  
  647.  
  648.  
  649.  
  650. INTERNET-DRAFT                    Packetization of H.261
  651.  
  652.  
  653. The format of the video-nack option is as follow:
  654.  
  655.   0                   1                   2                   3
  656.   0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  657.  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  658.  |F|    RAD      |  length = 3   |   Type        | Z |   Flow    |
  659.  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  660.  |     FGOBL     |     LGOBL     |    MBZ                |  FMT  |
  661.  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  662.  | timestamp (seconds)           | timestamp (fraction)          |
  663.  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  664.  
  665. The different fields have the following values:
  666.  
  667.     _____________________________________________________
  668.    | F         |   Last option bit, as defined by RTP.  |
  669.    |___________|________________________________________|
  670.    | RAD       |   RAD option type (65)                 |
  671.    |___________|________________________________________|
  672.    | Length    |   Three 32 bits word.                  |
  673.    |___________|________________________________________|
  674.    | Type      |   NACK (1).                            |
  675.    |___________|________________________________________|
  676.    | MBZ       |   Must be zero                         |
  677.    |___________|________________________________________|
  678.    | Flow      |   The flow id of the incoming packets  |
  679.    |___________|________________________________________|
  680.    | FGOBL     |   First GOB Lost:                      |
  681.    |           |   Identifies the first GOB lost number.|
  682.    |___________|________________________________________|
  683.    | LGOBL     |   Last GOB Lost:                       |
  684.    |           |   Identifies the last GOB lost number. |
  685.    |___________|________________________________________|
  686.    | MBZ       |   Must be zero                         |
  687.    |___________|________________________________________|
  688.    | FMT       |   Repeat the format indicator of the   |
  689.    |           |   received image, including the number |
  690.    |           |   of the SCIF subimage if present.     |
  691.    |___________|________________________________________|
  692.    | Timestamp |   The RTP timestamp of the             |
  693.    |           |   original image                       |
  694.    |___________|________________________________________|
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703. Turletti, Huitema                                    [Page 12]
  704.  
  705.  
  706.  
  707.  
  708.  
  709. INTERNET-DRAFT                    Packetization of H.261
  710.  
  711.  
  712. 7.  References
  713.  
  714. [1]  Video codec for audiovisual services at p x 64 kbit/s
  715.      CCITT Recommendation H.261, 1990.
  716.  
  717. [2]  Thierry Turletti. H.261 software codec for
  718.      videoconferencing over the Internet INRIA Research Report
  719.      no 1834, January 1993.
  720.  
  721. [3]  Henning Schulzrinne A Transport Protocol for Real-Time
  722.      Applications INTERNET-DRAFT, December 15, 1992.
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731.  
  732.  
  733.  
  734.  
  735.  
  736.  
  737.  
  738.  
  739.  
  740.  
  741.  
  742.  
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749.  
  750.  
  751.  
  752.  
  753.  
  754.  
  755.  
  756.  
  757.  
  758.  
  759.  
  760.  
  761.  
  762. Turletti, Huitema                                    [Page 13]
  763.  
  764.  
  765.  
  766.  
  767.  
  768. INTERNET-DRAFT                    Packetization of H.261
  769.  
  770.  
  771. Appendix A
  772.  
  773. The following code can be used to packetize the output of an
  774. H.261 codec:
  775.  
  776. #include <stdio.h>
  777.  
  778. #define BUFFER_MAX 512
  779.  
  780. int right[] = {
  781.    /* Number of successives zeroes starting at the MSB for
  782. each octet */
  783.    8,7,6,6,5,5,5,5,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
  784.    2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
  785.    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  786.    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  787.    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  788.    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  789.    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  790.    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  791.  
  792. int left[] = {
  793.    /* Number of successives zeroes starting at the LSB for
  794. each octet */
  795.    8,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
  796.    5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
  797.    6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
  798.    5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
  799.    7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
  800.    5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
  801.    6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
  802.    5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0};
  803.  
  804. h261_sync(F)
  805.    FILE *F;
  806. {
  807.    int  i, ebit, sbit, start_of_group, end_of_group,
  808.          c, nz;
  809.    unsigned char buf[BUFFER_MAX];
  810.    int *left, *right;
  811.  
  812.    i = 0;
  813.    ebit = 0;
  814.    sbit = 0;
  815.    start_of_group = 1;
  816.  
  817.  
  818.  
  819.  
  820.  
  821. Turletti, Huitema                                    [Page 14]
  822.  
  823.  
  824.  
  825.  
  826.  
  827. INTERNET-DRAFT                    Packetization of H.261
  828.  
  829.  
  830.    nz = 0;
  831.    while (c = getc(F)) {
  832.       buf[i++] = c;
  833.       if (c == 0) {
  834.          nz += 8;
  835.       } else {
  836.          nz += right[c];
  837.          end_of_group = 1;
  838.          if (nz >= 15) {
  839.             if (right[c] == 7) {
  840.                ebit = 0;
  841.                send_message(buf, i - 2, sbit, ebit,
  842.                   end_of_group, start_of_group);
  843.                sbit = 0;
  844.                i = 0;
  845.             } else {
  846.                ebit = 7 - right[c];
  847.                send_message(buf, i - 2, sbit, ebit,
  848.                   end_of_group, start_of_group);
  849.                i = 0;
  850.                buf[i++] = c;
  851.                sbit = right[c] + 1;
  852.             }
  853.             start_of_group = 1;
  854.          } else {
  855.             nz = left[c];
  856.             if (i >= BUFFER_MAX) {
  857.                ebit = 0;
  858.                end_of_group = 0;
  859.                send_message(buf, i - 2, sbit, ebit,
  860.                   end_of_group, start_of_group);
  861.                buf[0] = buf[i - 2];
  862.                buf[1] = buf[i - 1];
  863.                i = 2;
  864.                sbit = 0;
  865.                start_of_group = 0;
  866.             }
  867.          }
  868.       }
  869.    }
  870. }
  871.  
  872.  
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879.  
  880. Turletti, Huitema                                    [Page 15]
  881.  
  882.  
  883.  
  884.  
  885.  
  886. INTERNET-DRAFT                    Packetization of H.261
  887.  
  888.  
  889. Table of Contents
  890.  
  891.  
  892. 1 Status of this Memo ...................................    1
  893. 2 Abstract ..............................................    2
  894. 3 Purpose of this document ..............................    3
  895. 4 Structure of the packet stream ........................    3
  896. 5 Usage of RTP ..........................................    7
  897. 6 Usage of RTP parameters ...............................   10
  898. 6.1 Controlling the reverse flow ........................   10
  899. 6.2 Full Intra Request ..................................   10
  900. 6.3 Negative Acknowledgements ...........................   11
  901. 7 References ............................................   13
  902.  Appendix A .............................................   14
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929.  
  930.  
  931.  
  932.  
  933.  
  934.  
  935.  
  936.  
  937.  
  938.  
  939. Turletti, Huitema                                    [Page 16]
  940.  
  941.